<?php
function cleanWhitespace($str) {
	$stuff = explode("\n",$str);
	foreach($stuff as &$str) $str = trim($str);
	return implode("\n",$stuff);
}

$ld = new LittleDiff();
$first = array_shift($note_history);
$second = array_shift($note_history);
$firstTitle = 'Revision #' . $first['Version'];
$secondTitle = 'Revision #' . $second['Version'];

$table = $ld->diff(cleanWhitespace($first['Text']),cleanWhitespace($second['Text']),$firstTitle,$secondTitle);
?>
<?php echo use_helper('Form'); ?>

<?php slot('coursesNav', 'active') ?>
<div id="wrapper">
	<?php include_partial('global/systemMessages') ?>
	<div id="content">
	<!-- 
		<div id="location-bar">
			<form method="post" action="">
				<fieldset>
					<select>
						<option>Harvard</option>
					</select>
				</fieldset>
			</form>
			<ul class="breadcrumbs">
				<li class="first"><a href="#">Fall 2008</a> &#xBB;</li>
				<li><a href="#">Positive Psychology</a> &#xBB;</li>
				<li>Write Notes</li>
			</ul>
		</div>
	-->	
		<div id="main">
			<div class="main-heading">
				<h1><?php echo $second['Topic']; ?></h1>
				<h2><?php echo $subject_name; ?> - <?php echo $course_name; ?></h2>
				<?php if($second['VersionCreatedBy']) { ?>
					<div><?php echo link_to($second['user']->getUsername(),'profile/show?id=' . $second['VersionCreatedBy']); ?></div>
				<?php } ?>
			</div>
			<div class="notes">
					<div style="text-align: right;">
						<?php echo link_to('History', 'notes/history?id='.$root_note->getId())?> | 
						<?php echo link_to('Edit', 'notes/edit?id='.$root_note->getId())?> | 
						<?php echo link_to('View', 'notes/show?id='.$root_note->getId())?>
					</div>
			</div>



<div>
<?php echo $table['table']; ?>
</div>


<div class="main-heading"></div>


<div>
	<h2>Current Version</h2>
	<p>&nbsp;</p>
	<div class="currentVersion">
		<?php echo $current_version['Text']; ?>
	</div>
</div>

		<!-- 
			<div class="article-rating">
				<div class="btn_ratings">
					<ul class="star-rating">
						<li style="width: 60%;" class="current-rating">Currently 3/5 Stars.</li>
						<li>
							<a class="one-star" title="1 star out of 5" href="#">1</a>
						</li>
						<li>
							<a class="two-stars" title="2 stars out of 5" href="#">2</a>
						</li>
						<li>
							<a class="three-stars" title="3 stars out of 5" href="#">3</a>
						</li>
						<li>
							<a class="four-stars" title="4 stars out of 5" href="#">4</a>
						</li>
						<li>
							<a class="five-stars" title="5 stars out of 5" href="#">5</a>
						</li>
					</ul>
				</div>
			</div>-->
		
		</div>
		
		<div id="sidebar">
			<?php include_component('courses', 'about', array('course_id' => $root_note->getCourseId()))?>	
		
			<?php include_component('notes', 'relatedGroups', array('course_id' => $root_note->getCourseId()))?>
			
			<?php include_component('notes', 'related', array('course_id' => $root_note->getCourseId()))?>

		</div>
	</div>
	
</div>
